import 'dart:io';

import 'package:wechat_assets_picker/wechat_assets_picker.dart';

import '../../../app_files.dart';
import 'package:azlistview/azlistview.dart';

import '../../../app_files.dart';

class MainViewModel {
  final int normalNumber;
  final int generalNumber;
  final int seriousNumber;
  final int fixNumber;

  final String todayCheck;
  final String todayFix;
  final int allCheck;
  final String unCheck;
  final String communityNumber;

//  final String normalScale;
  final int totalCheck;

  String get safeScale {
    if (totalCheck == 0) return '0%';
    String scale = (allCheck / totalCheck * 100).toStringAsFixed(0);
    return '$scale%';
  }

  String get normalScale {
    if (allCheck == 0) return '0%';
    String scale = (normalNumber / allCheck * 100).toStringAsFixed(0);
    return '$scale%';
  }

  final int newFixOrder;
  final int unFixOrder;
  final int fixingOrder;
  final int fixedOrder;
  final int allFixOrder;

  const MainViewModel({
    this.normalNumber = 0,
    this.generalNumber = 0,
    this.seriousNumber = 0,
    this.fixNumber = 0,
    this.todayCheck = '0',
    this.todayFix = '0',
    this.allCheck = 0,
    this.unCheck = '0',
    this.communityNumber = '0',
    this.newFixOrder = 0,
    this.unFixOrder = 0,
    this.fixedOrder = 0,
    this.fixingOrder = 0,
    this.allFixOrder = 0,
    this.totalCheck,
  });

  static fromSafeUser(json) {
    return MainViewModel(
      normalNumber:
          int.tryParse(CommonUtils.checkNullToString(json['normal'])) ?? 0,
      generalNumber:
          int.tryParse(CommonUtils.checkNullToString(json['hidden'])) ?? 0,
      seriousNumber:
          int.tryParse(CommonUtils.checkNullToString(json['maintenance'])) ?? 0,
      fixNumber:
          int.tryParse(CommonUtils.checkNullToString(json['selfStudy'])) ?? 0,
      todayCheck: CommonUtils.checkNullToString(json['nowChecked']),
      communityNumber: CommonUtils.checkNullToString(json['communtityNum']),
      allCheck:
          int.tryParse(CommonUtils.checkNullToString(json['checked'])) ?? 0,
      unCheck: CommonUtils.checkNullToString(json['waitChecked']),
    );
  }

  static fromLeaderUser(json) {
    return MainViewModel(
      normalNumber: json['CommonTotal'],
      generalNumber: json['WarnTotal'],
      seriousNumber: json['DangerTotal'],
      todayCheck: CommonUtils.checkNullToString(json['TodayTotal']),
      communityNumber: CommonUtils.checkNullToString(json['CommunityTotal']),
      allCheck: json['DoTotal'],
      unCheck: CommonUtils.checkNullToString(json['UnDoTotal']),
    );
  }

  static fromFixUser(json) {
    return MainViewModel(
      todayCheck: CommonUtils.checkNullToString(json['todayTask']),
      newFixOrder: json['newTask'],
      unFixOrder: json['receiveTask'],
      fixingOrder: json['inFix'],
      fixedOrder: json['fixed'],
    );
  }

  static fromSafeCount(json) {
    int all =
        int.tryParse(CommonUtils.checkNullToString(json['waitChecked'])) ??
            0 + int.tryParse(json['checked']) ??
            0;
    return MainViewModel(
      todayCheck: CommonUtils.checkNullToString(json['nowChecked']),
      normalNumber: int.tryParse(json['normal']) ?? 0,
      generalNumber: int.tryParse(json['hidden']) ?? 0,
      seriousNumber: int.tryParse(json['maintenance']) ?? 0,
      fixNumber: int.tryParse(json['selfStudy']) ?? 0,
      communityNumber: CommonUtils.checkNullToString(json['communtityNum']),
      allCheck: json['checked'],
      unCheck: CommonUtils.checkNullToString(json['waitChecked']),
      totalCheck: all,
    );
  }

  static fromPatrolUser(json) {
    return MainViewModel(
      normalNumber:
          int.tryParse(CommonUtils.checkNullToString(json['zhengchangNum'])) ??
              0,
      generalNumber:
          int.tryParse(CommonUtils.checkNullToString(json['yinhuanNum'])) ?? 0,
      seriousNumber:
          int.tryParse(CommonUtils.checkNullToString(json['weixiuNum'])) ?? 0,
      fixNumber:
          int.tryParse(CommonUtils.checkNullToString(json['zixiuNum'])) ?? 0,
      todayCheck: CommonUtils.checkNullToString(json['nowFinishNum']),
      communityNumber: CommonUtils.checkNullToString(json['pianquNum']),
      allCheck:
          int.tryParse(CommonUtils.checkNullToString(json['finishNum'])) ?? 0,
      unCheck: CommonUtils.checkNullToString(json['waitFinishNum']),
    );
  }

  static fromPatrolLeader(json) {
    int all = json['waitFinishNum'] + json['finishNum'];
    print(all);
    return MainViewModel(
      normalNumber:
          int.tryParse(CommonUtils.checkNullToString(json['zhengchangNum'])) ??
              0,
      generalNumber:
          int.tryParse(CommonUtils.checkNullToString(json['yinhuanNum'])) ?? 0,
      seriousNumber:
          int.tryParse(CommonUtils.checkNullToString(json['weixiuNum'])) ?? 0,
      fixNumber:
          int.tryParse(CommonUtils.checkNullToString(json['zixiuNum'])) ?? 0,
      todayCheck: CommonUtils.checkNullToString(json['nowFinishNum']),
      communityNumber: CommonUtils.checkNullToString(json['pianquNum']),
      allCheck:
          int.tryParse(CommonUtils.checkNullToString(json['finishNum'])) ?? 0,
      unCheck: CommonUtils.checkNullToString(json['waitFinishNum']),
      totalCheck: all,
    );
  }
}

class LeaderItemModel {
  final String userHead;
  final String userName;
  final String phone;
  final String userID;
  final int totalNumber;
  final int checkedNumber;
  final String unCheckNumber;
  final int normalNumber;
  final String generalNumber;
  final String seriousNumber;
  final String fixNumber;

  /// 0 安检 1 巡检
  final int type;

  const LeaderItemModel({
    this.userName,
    this.userHead,
    this.phone,
    this.totalNumber,
    this.checkedNumber,
    this.unCheckNumber,
    this.normalNumber,
    this.generalNumber,
    this.seriousNumber,
    this.userID,
    this.fixNumber,
    this.type,
  });

  String get checkScale {
    if (totalNumber == 0) return '0%';
    String scale = (checkedNumber / totalNumber * 100).toStringAsFixed(0);
    return '$scale%';
  }

  String get commonScale {
    if (checkedNumber == 0) return '0%';
    String scale = (normalNumber / checkedNumber * 100).toStringAsFixed(0);
    return '$scale%';
  }

  static fromJson(json, {int type = 0}) {
    return LeaderItemModel(
      userID: CommonUtils.checkNullToString(json['userId']),
      userName: CommonUtils.checkNullToString(json['userName']),
      userHead: CommonUtils.checkNullToString(json['AdminPhoto']),
      phone: CommonUtils.checkNullToString(json['phonenumber']),
      normalNumber:
          int.tryParse(CommonUtils.checkNullToString(json['normal'])) ?? 0,
      generalNumber: CommonUtils.checkNullToString(json['hidden']),
      seriousNumber: CommonUtils.checkNullToString(json['maintenance']),
      unCheckNumber: CommonUtils.checkNullToString(json['waitChecked']),
      fixNumber: CommonUtils.checkNullToString(json['study']),
      checkedNumber:
          int.tryParse(CommonUtils.checkNullToString(json['checked'])) ?? 0,
      totalNumber:
          int.tryParse(CommonUtils.checkNullToString(json['total'])) ?? 0,
      type: type,
    );
  }
}

class CommunityItemModel {
  final String name;
  final String address;
  final String states;
  final int checkNumber;
  final int unCheckNumber;
  final String normalNumber;
  final String generalNumber;
  final String seriousNumber;
  final String fixNumber;
  final String itemID;
  final String planID;
  final String planName;

  const CommunityItemModel({
    this.name,
    this.address,
    this.states,
    this.checkNumber,
    this.unCheckNumber,
    this.normalNumber,
    this.generalNumber,
    this.seriousNumber,
    this.fixNumber,
    this.itemID,
    this.planID,
    this.planName,
  });

  String get statusName {
    switch (states) {
      case '1':
        return '待安检';
      case '2':
        return '安检中';
      case '3':
        return '已完成';
      case '4':
        return '已中止';
      case '5':
        return '已关闭';
      default:
        return '未知';
    }
  }

  static fromJson(json) {
    int totalNumber = json['communtityNeedcheckusernum'] ?? 0;
    int checkNumber = json['communtityCheckednum'] ?? 0;
    return CommunityItemModel(
      itemID: CommonUtils.checkNullToString(json['communtityCommuntityid']),
      name: CommonUtils.checkNullToString(json['communtityCommuntityname']),
      address: CommonUtils.checkNullToString(json['CommunityAddress']),
      states: json['communtityStatus'],
      checkNumber: checkNumber,
      unCheckNumber: totalNumber - checkNumber,
      normalNumber: CommonUtils.checkNullToString(json['normal']),
      generalNumber: CommonUtils.checkNullToString(json['hidden']),
      seriousNumber: CommonUtils.checkNullToString(json['maintenance']),
      fixNumber: CommonUtils.checkNullToString(json['selfStudy']),
      planID: CommonUtils.checkNullToString(json['communtitySctaskid']),
      planName: CommonUtils.checkNullToString(json['sctaskName']),
    );
  }
}

class CheckListItemModel {
  final String userName;
  final String userAddress;
  String phone;
  final String userStatus;

  ///1居民 2非居民
  final String userType;
  final String checkTime;
  final bool checked;
  final String inDoorStatus;
  final String inDoorStatusStr;
  final String checkStatus;
  final String userID;
  final String communityID;
  String orderID;
  final String checkOrderNo;
  final String userNo;
  final String communityName;
  final String meterNo;
  final String meterType;

  String get checkStatusStr {
    switch (checkStatus) {
      case '1':
        return '正常';
      case '2':
        return '自修';
      case '3':
        return '隐患';
      case '4':
        return '维修';
      default:
        return '未知';
    }
  }

  CheckListItemModel({
    this.userName,
    this.userAddress,
    this.phone,
    this.userStatus,
    this.userType,
    this.checkTime,
    this.checked,
    this.checkStatus,
    this.userID,
    this.communityID,
    this.orderID,
    this.inDoorStatus,
    this.inDoorStatusStr,
    this.checkOrderNo,
    this.userNo,
    this.communityName,
    this.meterNo,
    this.meterType = '',
  });

  bool get isICGasUser => meterType == '2';

  static fromJson(json, communityID, communityName) {
    return CheckListItemModel(
      userID: CommonUtils.checkNullToString(json['scworkUserid']),
      userName: CommonUtils.checkNullToString(json['scworkUsername']),
      userAddress: CommonUtils.checkNullToString(json['scworkAddress']),
      phone: CommonUtils.checkNullToString(json['scworkUsertel']),
      // userStatus: CommonUtils.checkNullToString(json['UserStatus']),
      userType: CommonUtils.checkNullToString(json['scworktUserType']),
      checked:
          CommonUtils.checkNullToString(json['scworkResultstatus']).length != 0,
      checkStatus: CommonUtils.checkNullToString(json['scworkResultstatus']),
      checkTime: CommonUtils.checkNullToString(json['scworkCheckdate']),
      orderID: CommonUtils.checkNullToString(json['scworkId']),
      communityID: communityID,
      inDoorStatus: CommonUtils.checkNullToString(json['scworkDoorstatus']),
      inDoorStatusStr:
          CommonUtils.checkNullToString(json['scworkDoorstatusName']),
      checkOrderNo: CommonUtils.checkNullToString(json['scworkId']),
      userNo: CommonUtils.checkNullToString(json['scworkUserNo']),
      communityName: communityName,
      meterNo: CommonUtils.checkNullToString(json['scworkUserMeterNo']),
      meterType: CommonUtils.checkNullToString(json['MeterType']),
    );
  }
}

class FixListItemModel {
  final String title;
  final String userName;
  final String phone;
  final String address;
  final String itemID;
  String status;
  final String problemContent;
  final String images;
  final String userNo;
  final String itemType;
  final String result;
  final String meterContent;
  final String endTime;
  final String startTime;
  final String dispatchTime;
  final String createTime;
  final String content;
  String installType;
  final String bizDeviceType;
  final String userAccount;
  final String rezGastype;
  final String isAppointment;
  final Map businessExtend;

  String get itemTypeStr {
    switch (itemType) {
      case '1':
        return '工程挂表';
      case '2':
        return '故障报修';
      case '6':
        return '点火通气';
      case '9':
        return '工程抢修';
      case '3':
        return '置换通气';
      case '4':
        return '安检维修';
      case '7':
        return '改管报装';
      case '5':
        return '巡检维修';
      default:
        return '未知';
    }
  }

  String get installTypeStr {
    if (installType.isNotEmpty) {
      List items = [];
      List type = installType.split(',');
      if (type.contains('1')) items.add('壁挂炉');
      if (type.contains('2')) items.add('热水器');
      if (type.contains('3')) items.add('灶具');
      return items.join(',');
    }
    return '无需安装';
  }

  String get bizDeviceTypeStr {
    if (bizDeviceType.isNotEmpty) {
      List items = [];
      List type = bizDeviceType.split(',');
      if (type.contains('1')) items.add('报警器');
      if (type.contains('2')) items.add('自闭阀');
      return items.join(',');
    }
    return '无需安装';
  }

  String get itemResult {
    if (result == '1') return '已解决';
    return '未解决';
  }

  String get appointmentStr {
    if (status != '1' && status != '2') return '';
    if (isAppointment == '1') return '已预约';
    return '未预约';
  }

  String get titleStr {
    if (title.isEmpty || title == 'NULL') return userName;
    return title;
  }

  FixListItemModel({
    this.title,
    this.userName,
    this.phone,
    this.address,
    this.itemID,
    this.status,
    this.problemContent,
    this.images,
    this.userNo,
    this.itemType,
    this.result,
    this.meterContent,
    this.installType,
    this.bizDeviceType,
    this.endTime,
    this.createTime,
    this.startTime,
    this.dispatchTime,
    this.content,
    this.userAccount,
    this.rezGastype,
    this.isAppointment,
    this.businessExtend,
  });

  static fromJson(json) {
    return FixListItemModel(
      title: CommonUtils.checkNullToString(json['bizCommuntityname']),
      userName: CommonUtils.checkNullToString(json['bizUsername']),
      phone: CommonUtils.checkNullToString(json['bizUsertel']),
      address: CommonUtils.checkNullToString(json['bizAddress']),
      itemID: CommonUtils.checkNullToString(json['bizId']),
      status: CommonUtils.checkNullToString(json['bizStatus']),
      images: CommonUtils.checkNullToString(json['bizFiles']),
      userNo: CommonUtils.checkNullToString(json['bizUserid']),
      itemType: CommonUtils.checkNullToString(json['bizType']),
      problemContent: CommonUtils.checkNullToString(json['bizContent']),
      result: CommonUtils.checkNullToString(json['bizResult']),
      meterContent: CommonUtils.checkNullToString(json['bizMetercontent']),
      installType: CommonUtils.checkNullToString(json['bizAppliancetype']),
      bizDeviceType: CommonUtils.checkNullToString(json['bizDevicetype']),
      endTime: CommonUtils.checkNullToString(json['bizEnddate']),
      dispatchTime: CommonUtils.checkNullToString(json['bizDispatchtime']),
      createTime: CommonUtils.checkNullToString(json['createTime']),
      startTime: CommonUtils.checkNullToString(json['bizStartdate']),
      content: CommonUtils.checkNullToString(json['bizContent']),
      userAccount: CommonUtils.checkNullToString(json['bizUserno']),
      rezGastype: CommonUtils.checkNullToString(json['rezGastype']),
      isAppointment: CommonUtils.checkNullToString(json['bizIsAppointment']),
      businessExtend: json['securitycheckBusinessExtend'] ?? {},
    );
  }

  @override
  bool operator ==(other) {
    if (other.runtimeType != runtimeType) return false;
    final FixListItemModel typedOther = other;
    return typedOther.itemID == itemID;
  }

  @override
  int get hashCode => itemID.hashCode;
}

class CountLeaderModel {
  final String totalMoney;
  final String todayCount;
  final String monthMoney;
  final String yearMoney;

  final String wxMoney;
  final String wxCount;

  final String cashMoney;
  final String cashCount;

  final String nhMoney;
  final String nhCount;

  final String zfbMoney;
  final String zfbCount;
  final String officialMoney;
  final String officialCount;
  final String appMoney;
  final String appCount;

  final String storeNum;
  final String numberPB;
  final String numberKB;
  final String numberYCB;
  final String totalUser;

  final String newOpenToday;
  final String newOpenPB;
  final String newOpenKB;
  final String newOpenYCB;

  final MainViewModel safeModel;
  final FixCountModel fixModel;
  final MainViewModel patrolModel;

  const CountLeaderModel({
    this.newOpenKB,
    this.newOpenPB,
    this.todayCount,
    this.totalMoney,
    this.wxCount,
    this.wxMoney,
    this.cashCount,
    this.cashMoney,
    this.nhCount,
    this.nhMoney,
    this.storeNum,
    this.numberKB,
    this.numberPB,
    this.numberYCB,
    this.safeModel,
    this.fixModel,
    this.totalUser,
    this.monthMoney,
    this.yearMoney,
    this.newOpenToday,
    this.zfbCount,
    this.zfbMoney,
    this.officialCount,
    this.officialMoney,
    this.appCount,
    this.appMoney,
    this.newOpenYCB,
    this.patrolModel,
  });

  static fromJson(json, safeModel, fixModel) {
    return CountLeaderModel(
      cashCount: CommonUtils.checkNullToString(json['PayCountCash']),
      cashMoney: CommonUtils.checkNullToString(json['PaySumCash']),
      newOpenKB: CommonUtils.checkNullToString(json['OpenCardToday']),
      newOpenPB: CommonUtils.checkNullToString(json['OpenMachToday']),
      nhCount: CommonUtils.checkNullToString(json['PayCountOnlineBank']),
      nhMoney: CommonUtils.checkNullToString(json['PaySumOnlineBank']),
      wxCount: CommonUtils.checkNullToString(json['PayCountHallWx']),
      wxMoney: CommonUtils.checkNullToString(json['PaySumHallWx']),
      todayCount: CommonUtils.checkNullToString(json['OrderPayCountToday']),
      totalMoney: CommonUtils.checkNullToString(json['PaySumToday']),
      storeNum: '1',
      numberKB: CommonUtils.checkNullToString(json['CardUserTotal']),
      numberPB: CommonUtils.checkNullToString(json['MachCardUserTotal']),
      numberYCB: '0',
      totalUser: CommonUtils.checkNullToString(json['UserTotal']),
      safeModel: safeModel,
      fixModel: fixModel,
      monthMoney: CommonUtils.checkNullToString(json['PaySumMonth']),
      yearMoney: CommonUtils.checkNullToString(json['PaySumYear']),
      newOpenToday:
          CommonUtils.checkNullToString(json['OpenAccountCountToday']),
    );
  }

  static fromFugouSafeCount(json, safeModel, fixModel, patrolModel) {
    return CountLeaderModel(
      cashCount: CommonUtils.checkNullToString(json['PerCashCount']),
      cashMoney: CommonUtils.checkNullToString(json['PerCashFee']),
      nhCount: CommonUtils.checkNullToString(json['PerOnlineBankCount']),
      nhMoney: CommonUtils.checkNullToString(json['PerOnlineBankFee']),
      wxCount: CommonUtils.checkNullToString(json['PerWxCount']),
      wxMoney: CommonUtils.checkNullToString(json['PerWxFee']),
      todayCount: CommonUtils.checkNullToString(json['PerPerCount']),
      totalMoney: CommonUtils.checkNullToString(json['PerPerPaid']),
      storeNum: '1',
      numberKB: CommonUtils.checkNullToString(json['CardUserTotal']),
      numberPB: CommonUtils.checkNullToString(json['MachCardUserTotal']),
      numberYCB: CommonUtils.checkNullToString(json['WlwUserTotal']),
      totalUser: CommonUtils.checkNullToString(json['UserTotal']),
      newOpenKB: CommonUtils.checkNullToString(json['OpenCardToday']),
      newOpenPB: CommonUtils.checkNullToString(json['OpenMachToday']),
      newOpenYCB: CommonUtils.checkNullToString(json['OpenWlwToday']),
      newOpenToday:
          CommonUtils.checkNullToString(json['OpenAccountCountToday']),
      safeModel: safeModel,
      fixModel: fixModel,
      patrolModel: patrolModel,
      monthMoney: CommonUtils.checkNullToString(json['PaySumMonth']),
      yearMoney: CommonUtils.checkNullToString(json['PaySumYear']),
      zfbCount: CommonUtils.checkNullToString(json['PerAliPayCount']),
      zfbMoney: CommonUtils.checkNullToString(json['PerAliPayFee']),
      officialCount: CommonUtils.checkNullToString(json['PerOfficialCount']),
      officialMoney: CommonUtils.checkNullToString(json['PerOfficialFee']),
      appCount: CommonUtils.checkNullToString(json['PerAppCount']),
      appMoney: CommonUtils.checkNullToString(json['PerAppFee']),
    );
  }
}

class FixCountModel {
  final int totalNumber;
  final String todayTotal;
  final int newTotal;
  final int unReceiveTotal;
  final int fixedTotal;
  final int doTotal;
  final int ingTotal;
  final String fixRate;
  final String receiveRate;

  int get sendTotal => unReceiveTotal;

  String get fixScale {
    return '$fixRate%';
  }

  String get getScale {
    return '$receiveRate%';
  }

  const FixCountModel({
    this.totalNumber,
    this.todayTotal,
    this.newTotal,
    this.fixedTotal,
    this.doTotal,
    this.ingTotal,
    this.fixRate,
    this.receiveRate,
    this.unReceiveTotal,
  });

  static fromJson(json) {
    return FixCountModel(
      totalNumber: json['totalNum'],
      todayTotal: CommonUtils.checkNullToString(json['todayTask']),
      newTotal: json['daipaidan'],
      unReceiveTotal: json['newTask'],
      fixedTotal: json['fixed'],
      doTotal: json['inFix'],
      ingTotal: json['receiveTask'],
      receiveRate: CommonUtils.checkNullToString(json['receiveRate']),
      fixRate: CommonUtils.checkNullToString(json['finishRate']),
    );
  }
}

class InstallModel {
  final String totalMoney;
  final String totalNumber;
  final String communityNumber;

  const InstallModel({
    this.totalNumber,
    this.totalMoney,
    this.communityNumber,
  });

  static fromJson(json) {
    return InstallModel(
      totalMoney: CommonUtils.checkNullToString(json['TotalMoney']),
      totalNumber: CommonUtils.checkNullToString(json['TotalHouse']),
      communityNumber: CommonUtils.checkNullToString(json['TotalCommuntity']),
    );
  }
}

class InstallItemModel {
  final String name;
  final String address;
  final String phone;
  final String money;
  final String itemID;

  const InstallItemModel({
    this.name,
    this.address,
    this.phone,
    this.money,
    this.itemID,
  });

  static fromJson(json) {
    return InstallItemModel(
      name: CommonUtils.checkNullToString(json['OtherpayUsername']),
      address: CommonUtils.checkNullToString(json['OtherpayUserAddress']),
      phone: CommonUtils.checkNullToString(json['OtherpayUsermobile']),
      money: CommonUtils.checkNullToString(json['OtherpayPayment']),
      itemID: CommonUtils.checkNullToString(json['OtherpayId']),
    );
  }
}

class CommunityModel {
  final String name;
  final String itemID;

  const CommunityModel({
    this.name,
    this.itemID,
  });

  static fromJson(json) {
    return CommunityModel(
      name: CommonUtils.checkNullToString(json['CommunityName']),
      itemID: CommonUtils.checkNullToString(json['CommunityId']),
    );
  }
}

class PlanItemModel extends ISuspensionBean {
  final String planName;
  final String planValue;
  final String jobName;
  final String planType;

  @override
  String getSuspensionTag() => jobName;

  PlanItemModel({
    this.planName,
    this.planType,
    this.planValue,
    this.jobName,
  });

  static fromJson(json) {
    return PlanItemModel(
      planName: CommonUtils.checkNullToString(json['sctaskName']),
      planType: CommonUtils.checkNullToString(json['sctaskUsertype']),
      jobName: CommonUtils.checkNullToString(json['sctaskScplanname']),
      planValue: CommonUtils.checkNullToString(json['sctaskId']),
    );
  }
}

class FixWorkerModel {
  final String userID;
  final String userName;
  final String userPhone;

  const FixWorkerModel({
    this.userID,
    this.userName,
    this.userPhone,
  });

  static fromJson(json) {
    return FixWorkerModel(
      userID: CommonUtils.checkNullToString(json['userId']),
      userName: CommonUtils.checkNullToString(json['userName']),
      userPhone: CommonUtils.checkNullToString(json['phonenumber']),
    );
  }
}

class AssetEntityFile {
  AssetEntity assetEntity;
  File file;
  String url;
  File thumbFile;
  String fileId = '${DateTime.now().millisecondsSinceEpoch}.mp4';

  AssetEntityFile({
    this.assetEntity,
    this.file,
    this.url,
    this.thumbFile,
  });

  bool get isVideo {
    if (assetEntity != null) {
      return assetEntity.type == AssetType.video;
    }
    if (file != null) return file.path.split('.').last == 'mp4';
    if (url != null) return file.path.split('.').last == 'mp4';
    return false;
  }

  @override
  int get hashCode {
    if (assetEntity != null) {
      return assetEntity.id.hashCode ^ assetEntity.isFavorite.hashCode;
    }
    if (file != null) {
      return file.hashCode;
    }
    if (url != null) {
      return url.hashCode;
    }
    return 0;
  }

  @override
  bool operator ==(Object other) {
    if (other is! AssetEntityFile) {
      return false;
    }
    AssetEntityFile t = other as AssetEntityFile;
    if (assetEntity != null && t.assetEntity != null) {
      return assetEntity.id == t.assetEntity.id &&
          assetEntity.isFavorite == t.assetEntity.isFavorite;
    }
    if (file != null && t.file != null) {
      return file.path == t.file.path;
    }
    if (url != null && t.url != null) {
      return url == t.url;
    }
    return false;
  }
}
